var e = require("../../../uv-ui-tools/libs/mixin/mpMixin.js"), t = require("../../../uv-ui-tools/libs/mixin/mixin.js"), i = require("./props.js"), a = require("../../../../common/vendor.js");

require("../../../uv-ui-tools/libs/function/index.js"), require("../../../uv-ui-tools/libs/function/test.js"), 
require("../../../uv-ui-tools/libs/function/digit.js"), require("../../../uv-ui-tools/libs/util/route.js"), 
require("../../../uv-ui-tools/libs/function/debounce.js"), require("../../../uv-ui-tools/libs/function/throttle.js");

var n = {
    name: "uv-checkbox",
    mixins: [ e.mpMixin, t.mixin, i.props ],
    data: function() {
        return {
            isChecked: !1,
            parentData: {
                iconSize: 12,
                labelDisabled: null,
                disabled: null,
                shape: "square",
                activeColor: null,
                inactiveColor: null,
                size: 18,
                value: null,
                modelValue: null,
                iconColor: null,
                placement: "row",
                borderBottom: !1,
                iconPlacement: "left",
                labelSize: 14,
                labelColor: "#303133"
            }
        };
    },
    computed: {
        elDisabled: function() {
            return "" !== this.disabled ? this.disabled : null !== this.parentData.disabled && this.parentData.disabled;
        },
        elLabelDisabled: function() {
            return "" !== this.labelDisabled ? this.labelDisabled : null !== this.parentData.labelDisabled && this.parentData.labelDisabled;
        },
        elSize: function() {
            return this.size ? this.size : this.parentData.size ? this.parentData.size : 21;
        },
        elIconSize: function() {
            return this.iconSize ? this.iconSize : this.parentData.iconSize ? this.parentData.iconSize : 12;
        },
        elActiveColor: function() {
            return this.activeColor ? this.activeColor : this.parentData.activeColor ? this.parentData.activeColor : "#2979ff";
        },
        elInactiveColor: function() {
            return this.inactiveColor ? this.inactiveColor : this.parentData.inactiveColor ? this.parentData.inactiveColor : "#c8c9cc";
        },
        elLabelColor: function() {
            return this.labelColor ? this.labelColor : this.parentData.labelColor ? this.parentData.labelColor : "#606266";
        },
        elShape: function() {
            return this.shape ? this.shape : this.parentData.shape ? this.parentData.shape : "circle";
        },
        elLabelSize: function() {
            return this.$uv.addUnit(this.labelSize ? this.labelSize : this.parentData.labelSize ? this.parentData.labelSize : "15");
        },
        elIconColor: function() {
            var e = this.iconColor ? this.iconColor : this.parentData.iconColor ? this.parentData.iconColor : "#ffffff";
            return this.elDisabled ? this.isChecked ? this.elInactiveColor : "transparent" : this.isChecked ? e : "transparent";
        },
        iconClasses: function() {
            var e = [];
            return e.push("uv-checkbox__icon-wrap--" + this.elShape), this.elDisabled && e.push("uv-checkbox__icon-wrap--disabled"), 
            this.isChecked && this.elDisabled && e.push("uv-checkbox__icon-wrap--disabled--checked"), 
            e;
        },
        iconWrapStyle: function() {
            var e = {};
            return e.backgroundColor = this.isChecked && !this.elDisabled ? this.elActiveColor : "#ffffff", 
            e.borderColor = this.isChecked && !this.elDisabled ? this.elActiveColor : this.elInactiveColor, 
            e.width = this.$uv.addUnit(this.elSize), e.height = this.$uv.addUnit(this.elSize), 
            "right" === this.parentData.iconPlacement && (e.marginRight = 0), e;
        },
        checkboxStyle: function() {
            var e = {};
            return this.parentData.borderBottom && "row" === this.parentData.placement && this.$uv.error("检测到您将borderBottom设置为true，需要同时将uv-checkbox-group的placement设置为column才有效"), 
            this.parentData.borderBottom && "column" === this.parentData.placement && (e.paddingBottom = "8px"), 
            this.$uv.deepMerge(e, this.$uv.addStyle(this.customStyle));
        }
    },
    created: function() {
        this.init();
    },
    methods: {
        init: function() {
            var e = this;
            this.updateParentData(), this.parent || this.$uv.error("uv-checkbox必须搭配uv-checkbox-group组件使用"), 
            this.$nextTick(function() {
                var t = [];
                e.parentData.value.length ? t = e.parentData.value : e.parentData.modelValue.length && (t = e.parentData.modelValue), 
                e.checked ? e.isChecked = !0 : e.$uv.test.array(t) && (e.isChecked = t.some(function(t) {
                    return t === e.name;
                }));
            });
        },
        updateParentData: function() {
            this.getParentData("uv-checkbox-group");
        },
        wrapperClickHandler: function(e) {
            "right" === this.parentData.iconPlacement && this.iconClickHandler(e);
        },
        iconClickHandler: function(e) {
            this.preventEvent(e), this.elDisabled || this.setRadioCheckedStatus();
        },
        labelClickHandler: function(e) {
            this.preventEvent(e), this.elLabelDisabled || this.elDisabled || this.setRadioCheckedStatus();
        },
        emitEvent: function() {
            var e = this;
            this.$emit("change", this.isChecked), this.$nextTick(function() {
                e.$uv.formValidate(e, "change");
            });
        },
        setRadioCheckedStatus: function() {
            this.isChecked = !this.isChecked, this.emitEvent(), "function" == typeof this.parent.unCheckedOther && this.parent.unCheckedOther(this);
        }
    },
    watch: {
        checked: function() {
            this.isChecked = this.checked;
        }
    }
};

Array || a.resolveComponent("uv-icon")(), Math;

var l = a._export_sfc(n, [ [ "render", function(e, t, i, n, l, o) {
    return {
        a: a.p({
            name: "checkbox-mark",
            size: o.elIconSize,
            color: o.elIconColor
        }),
        b: a.o(function() {
            return o.iconClickHandler && o.iconClickHandler.apply(o, arguments);
        }),
        c: a.n(o.iconClasses),
        d: a.s(o.iconWrapStyle),
        e: a.t(e.label),
        f: o.elDisabled ? o.elInactiveColor : o.elLabelColor,
        g: o.elLabelSize,
        h: o.elLabelSize,
        i: a.o(function() {
            return o.labelClickHandler && o.labelClickHandler.apply(o, arguments);
        }),
        j: a.s(o.checkboxStyle),
        k: a.o(function() {
            return o.wrapperClickHandler && o.wrapperClickHandler.apply(o, arguments);
        }),
        l: a.n("uv-checkbox-label--".concat(l.parentData.iconPlacement)),
        m: a.n(l.parentData.borderBottom && "column" === l.parentData.placement && "uv-border-bottom")
    };
} ], [ "__scopeId", "data-v-351a1a67" ] ]);

wx.createComponent(l);